#include <bits/stdc++.h>

using namespace std;
const int M = 1e9 + 7;
int ans = 1, n;
int f[M];
void MinFibonacciNumbers(int x)
{
	f[1] = 1, f[2] = 1;
	for (int i = 1; i <= x; i++)
	{

		f[i] = f[i - 1] + f[i - 2];
	}
	for (int i = x; i >= 1; i--)
	{
		if (f[i] == x)
		{
			ans++;
			break;
		}
		else if (f[i] > x)
			i--;
		else if (f[i] < x)
		{
			x = x - f[i];
			ans++;
		}
	}
	cout << ans;
}
int main()
{
	cin >> n;

	MinFibonacciNumbers(n);

	return 0;
}
/*参考题解
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+50;

int MinFibonacciNumbers(int k)
{
	vector<int>f;//声明一个整形向量f，用于存储斐波那契数列
	f.push_back(1);
	f.push_back(1);
	while(1){
		if(f[f.size()-1]+f[f.size()-2]>1e9)
			break;
		f.push_back(f[f.size()-1]+f[f.size()-2]);
	}
	int cnt=0;
	for(int i=f.size()-1;i>=0;i--)//从斐波那契额数列的最后一个数开始向前遍历
	{
		if(k>=f[i])
		{
			cnt+=k/f[i];
			k=k-k/f[i]*f[i];
		}
		if(k==0)
			break;
	}
	return cnt;
	}

int main( )
{
	int n;
	cin>>n;

	cout<<MinFibonacciNumbers(n);

	return 0;
}
*/